package jifenbao.com.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import jifenbao.com.entity.MyEntity;
import jifenbao.com.jifenbao.R;

/**
 * Created by Administrator on 2016/5/31 0031.
 */
public class MyAdapter extends BaseAdapter{

    private List<MyEntity> EntityList;
    private Context context;
    public MyAdapter(Context context, List<MyEntity> EntityList){
        this.context = context;
        this.EntityList = EntityList;
    }
    @Override
    public int getCount() {
        return EntityList.size();
    }

    @Override
    public MyEntity getItem(int position) {
        return EntityList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
//        View view  = View.inflate(context, R.layout.activity_shop_ticket_valid,null);
//        return view;
        MyEntity myEntity = EntityList.get(position);
        FindTextView findTextView = null;
        if(convertView == null){
            convertView =View.inflate(context, R.layout.activity_shop_ticket_valid,null);
            findTextView = new FindTextView();
            findTextView.ticketvalueTV = (TextView) convertView.findViewById(R.id.ticket_value);
            findTextView.ticketnameTV = (TextView) convertView.findViewById(R.id.ticket_name);
            findTextView.ticketfullTV = (TextView) convertView.findViewById(R.id.ticket_full);
            convertView.setTag(findTextView);
        }else{
            findTextView = (FindTextView) convertView.getTag();
        }
        findTextView.ticketvalueTV.setText(myEntity.getTicketvalue());
        findTextView.ticketnameTV.setText(myEntity.getTicketname());
        findTextView.ticketfullTV.setText(myEntity.getTicketfull());
        return convertView;
    }
    private class FindTextView{
        TextView ticketvalueTV,ticketnameTV,ticketfullTV;
    }
}


